package it.evento.utils.genpage;

import javax.json.JsonArray;

/**
 *
 * @author Ilo
 */
public class ContentGenerator {
        
    /**
     * Gets the correct JSON structure for async POST with jQuery
     * 
     * @param jsonArray the {@JsonArray} to be converted
     * @return a string representation of the JSON structure
     */
    public static String getOutputJson(JsonArray jsonArray) {
        return jsonArray.toString().substring(1, jsonArray.toString().length()-1);
    }
    
    /**
     * Prints an error message
     * 
     * @param text the text of the error message
     * 
     * @return a string representation of the error
     */
    public static String printError(String text) {
        String ret = "";
        
        ret += "<div class='ui-widget'>";
            ret += "<div class='ui-state-error ui-corner-all' style='margin-top: 20px; padding: 0 .7em;'>";
		ret += "<p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span>";
		ret += "<b>" + text + "</b></p>";
            ret += "</div>";
        ret += "</div>";
        
        return ret;
    }
    
    /**
     * Prints a warning message
     * 
     * @param text the text of the warning message
     * 
     * @return a string representation of the warning
     */
    public static String printWarning(String text) {
        String ret = "";
        
        ret += "<div class='ui-widget'>";
            ret += "<div class='ui-state-highlight ui-corner-all' style='margin-top: 20px; padding: 0 .7em;'>";
		ret += "<p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span>";
		ret += text + "</p>";
            ret += "</div>";
        ret += "</div>";
        
        return ret;
    }
    
}
